package bit_exercises.Day20;


import java.io.*;
import java.util.*;
/**
 * @author zerorain
 * @date 2022/05/18 17:00
 **/
// 第一题 反转字符串
//public class Main {
//    public static void main(String[] args) {
//        Scanner sc = new Scanner(System.in);
//        String str = sc.nextLine();
//        StringBuffer sb = new StringBuffer(str);
//        System.out.println(sb.reverse());
//    }
//}

//第二题   最小公共子串  dp问题
public class Main
{
    public static int getMaxLen(String str1,String str2)
    {
        char[] arr1 = str1.toCharArray();
        char[] arr2 = str2.toCharArray();
        int len1 = arr1.length;
        int len2 = arr2.length;
        int[][] maxSubLen = new int[len1 + 1][len2 + 1];
        int maxLen = 0;
        for(int i = 1 ; i<= len1 ; i++){
            for(int j = 1 ; j <= len2 ; j++){
                if(arr1[i - 1] == arr2[j - 1]){
                    maxSubLen[i][j] = maxSubLen[i - 1][j - 1] + 1;
                    if(maxLen < maxSubLen[i][j]){
                        maxLen = maxSubLen[i][j];
                    }
                }
            }
        }
        return maxLen;
    }
    public static void main(String[] args) throws Exception{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String str1;
        String str2;
        while((str1 = reader.readLine()) != null){
            str2 = reader.readLine();
            System.out.println(getMaxLen(str1,str2));
        }
    }
}